<template>
    <div>
        <!-- 面包屑导航 -->
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>

        <!-- 内容区 -->
        <el-card class="box-card">
            <el-table :data="rightsList" stripe style="width: 100%">
                <!-- 表格索引列 -->
                <el-table-column type="index" width="50">
                </el-table-column>
                <el-table-column prop="id" label="id" width="180">
                </el-table-column>
                <el-table-column prop="authName" label="权限名称" width="180">
                </el-table-column>
                <el-table-column prop="path" label="对应路由">
                </el-table-column>
                <el-table-column label="权限层级">
                    <template v-slot="{row}">
                        <el-tag v-if="row.level === '0'">一级权限</el-tag>
                        <el-tag v-if="row.level === '1'" type="success">二级权限</el-tag>
                        <el-tag v-if="row.level === '2'" type="warning">三级权限</el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>

<script>
export default {
    name: 'RightsView',
    data: function () {
        return {
            rightsList: []
        }
    },
    methods: {
        async getRightsList() {
            const { data, meta: { msg, status } } = await this.$http.get(`rights/list`)
            if (status !== 200) {
                return this.$message.error(msg)
            }
            this.rightsList = data
            console.log(this.rightsList)
        }
    },
    mounted() {
        this.getRightsList()
    }
}
</script>

<style></style>